<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="line">
  <link rel="stylesheet" href="./assets/common.css">
  <title>miniTooltip</title>
  <style>
  </style>
</head>

<body>
<div id="canvas"></div>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/data-set.min.js"></script>
<script src="../build/g2.js"></script>
<script>
$.getJSON('./data/top2000.json', data => {
  const ds = new DataSet();
  const dv = ds.createView('test')
        .source(data)
        .transform({
          as: [ 'count' ],
          groupBy: [ 'release' ],
          operations: [ 'count' ],
          type: 'aggregate'
        });

  const chart = new G2.Chart({
    container: 'canvas',
    forceFit: true,
    height: window.innerHeight
  });
  chart.source(dv.rows);
  chart.scale({
    count: {
      alias: 'top2000 唱片总量'
    },
    release: {
      tickInterval: 5,
      alias: '唱片发行年份'
    }
  });
  chart.tooltip({
    type: 'mini'
  });
  chart.interval()
        .position('release*count')
        .color('#1890ff')
    .opacity(0.96);

  chart.render();
});
</script>
</body>

</html>
